<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:nwisdocs="http://wales.nhs.uk/nwis/docs"
	exclude-result-prefixes="xs xsi">

  <xsl:template name="other-information">

    <xsl:choose>
      <xsl:when test="(count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:MentalCapacity/*) &gt; 0) or (count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:PhysicalAbility/*) &gt; 0)or (count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:CognitiveFunction/*) &gt; 0)or (count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:AdvanceDecisions/*) &gt; 0)">
        <div class="boxed-section" id="{local-name()}">
          <h2>Any other important information</h2>
          <div class="inline-content">
            <xsl:choose>
              <xsl:when test="count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:MentalCapacity/*) &gt; 0">
                <h3>Mental capacity</h3>
                <p>
                  <xsl:value-of select="nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:MentalCapacity/nwisdocs:Narrative"/>
                </p>
              </xsl:when>
            </xsl:choose>


            <xsl:choose>
              <xsl:when test="count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:PhysicalAbility/*) &gt; 0">
                <h3>Measures of physical ability</h3>
                <p>
                  <xsl:value-of select="nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:PhysicalAbility/nwisdocs:Narrative"/>
                </p>
              </xsl:when>
            </xsl:choose>

            <xsl:choose>
              <xsl:when test="count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:CognitiveFunction/*) &gt; 0">
                <h3>Measures of cognitive function</h3>
                <p>
                  <xsl:value-of select="nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:CognitiveFunction/nwisdocs:Narrative"/>
                </p>
              </xsl:when>
            </xsl:choose>

            <xsl:choose>
              <xsl:when test="count(nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:AdvanceDecisions/*) &gt; 0">
                <h3>Advance decisions to refuse treatment</h3>
                <p>
                  <xsl:value-of select="nwisdocs:DocumentBody/nwisdocs:OtherInformation/nwisdocs:AdvanceDecisions/nwisdocs:Narrative"/>
                </p>
              </xsl:when>
            </xsl:choose>
          </div>
        </div>
      </xsl:when>
      <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
    
  </xsl:template>

</xsl:stylesheet>
